import request from '@/utils/request'

// 查询设备类型列表
export function listEquipmentType(query) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/list',
    method: 'get',
    params: query
  })
}

// 查询所有设备类型（不分页，用于树状结构）
export function listAllEquipmentType(query) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/listAll',
    method: 'get',
    params: query
  })
}

// 查询设备类型详细
export function getEquipmentType(id) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/' + id,
    method: 'get'
  })
}

// 新增设备类型
export function addEquipmentType(data) {
  return request({
    url: '/ldzl-sb/sb/equipment/type',
    method: 'post',
    data: data
  })
}

// 修改设备类型
export function updateEquipmentType(data) {
  return request({
    url: '/ldzl-sb/sb/equipment/type',
    method: 'put',
    data: data
  })
}

// 删除设备类型
export function delEquipmentType(id) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/' + id,
    method: 'delete'
  })
}

// 获取设备类型树形结构
export function getEquipmentTypeTree() {
  return request({
    url: '/ldzl-sb/sb/equipment/type/tree',
    method: 'get'
  })
} 

// 修改设备类型状态
export function changeEquipmentTypeStatus(data) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/changeStatus',
    method: 'put',
    data: data
  })
}

// 检查设备类型是否可以删除
export function checkCanDelete(typeId) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/checkDelete/' + typeId,
    method: 'get'
  })
}

// 检查设备类型编码是否唯一
export function checkTypeCode(typeCode) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/checkCode',
    method: 'get',
    params: { typeCode }
  })
} 

// 检查设备类型编码是否唯一（带ID）
export function checkTypeCodeUnique(data) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/checkCodeUnique',
    method: 'get',
    params: data
  })
}

// 根据类型名称生成编码
export function generateCodeFromName(typeName) {
  return request({
    url: '/ldzl-sb/sb/equipment/type/codeFromName',
    method: 'get',
    params: { typeName }
  })
} 